/*
 * Copyright 2010, 2011, 2012 mapsforge.org
 *
 * This program is free software: you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.mapsforge.android.maps.overlay;

import java.io.File;

import org.mapsforge.core.model.GeoPoint;

import android.graphics.drawable.Drawable;
import android.os.Bundle;

/**
 * OverlayItem holds all parameters of a single element on an {@link ItemizedOverlay}, such as position, marker, title
 * and textual description. If the marker is null, the default marker of the overlay will be drawn instead.
 */
public class KMLOverlayItem extends OverlayItem {
	/**
	 * ID of the KML feature that represents this item
	 */
	protected String kmlId;

	/**
	 * file that originated this Overlay. For future reference.
	 */
	protected File kmlFile;

	/**
	 * Undetermined feature attributes and/or fields that might be put there in the future
	 */
	protected Bundle extras;

	/**
	 * Constructs a new OverlayItem.
	 */
	public KMLOverlayItem() {
		this.cachedZoomLevel = Byte.MIN_VALUE;
	}

	/**
	 * @param point
	 *            the geographical position of the item (may be null).
	 * @param title
	 *            the title of the item (may be null).
	 * @param snippet
	 *            the short description of the item (may be null).
	 * @param id
	 *            the id associated to the kml feature that this overlay represents.
	 * @param file
	 *            the kml File that contains the kml feature being represented by this Item.
	 * @param extras
	 *            a Bundle that might or might not contain extra information regarding the item.
	 */
	public KMLOverlayItem(GeoPoint point, String title, String snippet, String id, File file, Bundle extras) {
		super(point, title, snippet);
		this.kmlId = id;
		this.kmlFile = file;
		this.extras = extras;
	}

	/**
	 * @param point
	 *            the geographical position of the item (may be null).
	 * @param title
	 *            the title of the item (may be null).
	 * @param snippet
	 *            the short description of the item (may be null).
	 * @param marker
	 *            the marker that is drawn for the item (may be null). The bounds of the marker must already have been
	 *            set properly, for example by calling {@link ItemizedOverlay#boundCenterBottom(Drawable)}.
	 * @param id
	 *            the id associated to the kml feature that this overlay represents.
	 * @param file
	 *            the kml File that contains the kml feature being represented by this Item.
	 * @param extras
	 *            a Bundle that might or might not contain extra information regarding the item.
	 */
	public KMLOverlayItem(GeoPoint point, String title, String snippet, Drawable marker, String id, File file,
			Bundle extras) {
		super(point, title, snippet, marker);
		this.kmlId = id;
		this.kmlFile = file;
		this.extras = extras;
	}

	/**
	 * @return the id associated to the kml feature that this overlay represents
	 */
	public synchronized String getKmlId() {
		return this.kmlId;
	}

	/**
	 * Sets the id associated with the kml feature that this overlay represents. This id should have been set by some
	 * KMLBinding generating the overlay from an actual kml file. And after that nobody should manually reset this id,
	 * but this method exists in spite of completeness.
	 * 
	 * @param kmlId
	 *            the id of the kml feature being represented by this Item
	 */
	public synchronized void setKmlId(String kmlId) {
		this.kmlId = kmlId;
	}

	/**
	 * @return the kml File that contains the kml feature being represented by this Item
	 */
	public synchronized File getKmlFile() {
		return this.kmlFile;
	}

	/**
	 * Sets the kml File that contains the feature being represented by this item. This parameter should've been set by
	 * some KMLBinding generating the overlay from a kml file. And after that nobody should manually reset this id, but
	 * this method is here in spite of completeness.
	 * 
	 * @param kmlFile
	 *            a kml File in the system that contains the kml feature that this item represents.
	 */
	public synchronized void setKmlFile(File kmlFile) {
		this.kmlFile = kmlFile;
	}

	/**
	 * @return a Bundle that might or might not contain extra information regarding the item.
	 */
	public synchronized Bundle getExtras() {
		return this.extras;
	}

	/**
	 * Sets extra information of this item.
	 * 
	 * @param extras
	 *            a Bundle containing extra information of this particular item. This make the KMLOverlayItem class
	 *            fairly more extensible than the OverlayItem...
	 */
	public synchronized void setExtras(Bundle extras) {
		this.extras = extras;
	}
}
